package org.itsolutions.javaBackup.core.tasks;

import java.util.List;

import org.itsolutions.javaBackup.exceptions.AException;
import org.itsolutions.javaBackup.logger.ELogLevel;
import org.itsolutions.javaBackup.logger.ILogger;
import org.itsolutions.javaBackup.logger.LoggerHelper;
import org.itsolutions.javaBackup.spi.backup.ftp.FTPFileWrapper;
import org.itsolutions.javaBackup.spi.backup.ftp.IFTPDownloadHandler;

import com.google.inject.Inject;

/**
 * 
 * @author Tomas Fecko
 */
public final class FTPBackupTask implements ITask<Boolean> {

	private static final ILogger 		LOGGER = LoggerHelper.getLogger(FTPBackupTask.class);
	private final IFTPDownloadHandler 	mFTPDownloadHandler;
	
	/**
	 * 
	 * @param pFTPDownloadHandler download manager
	 */
	@Inject FTPBackupTask(IFTPDownloadHandler pFTPDownloadHandler) {
		mFTPDownloadHandler = pFTPDownloadHandler;
	}

	@Override
	public Boolean execute() throws AException {
		mFTPDownloadHandler.connect("ftp", "anonymous", "anonymous@anonymous");
		List<FTPFileWrapper> listOfFiles = mFTPDownloadHandler.getListOfFiles("MP3");
		for (FTPFileWrapper file : listOfFiles) {
			LOGGER.log(ELogLevel.DEBUG, "File:", file);
		}
		mFTPDownloadHandler.disconnect();
		return true;
	}
}





